<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/include/taglib.jsp"%>
<html>
<head>
   	<title>${fns:getConfig('productName')}</title>
    <!-- <meta name="decorator" content="blank"/> --><!-- 如果使用装修则无法保证body的底色 -->
	<%@include file="/WEB-INF/view/include/comfile.jsp" %>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <link href="${ctxStatic}/css/plugins/iCheck/custom.css" rel="stylesheet">
    <script src="${ctxStatic}/js/plugins/iCheck/icheck.min.js"></script>
    <script src="${ctxStatic}/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${ctxStatic}/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${ctxStatic}/js/modules/sys/form-validate-user.js"></script>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins page-ibox">
                    <!-- <div class="ibox-title">
                    	<h3>用户信息 <small>包括自定义样式的复选和单选按钮</small></h3>
                    </div> -->
                    
	                <div class="ibox-content">
	                <form:form id="userForm" modelAttribute="user" action="${ctx}/sys/user/save" method="post" class="form-horizontal">
	                	<form:hidden path="id"/>
	                	<div class="info-split">
                           	 基本信息
                        </div>
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">姓名</label>
                            <div class="col-sm-8">
                                 <input name="name" type="text" class="form-control" value="${user.name}" >
                            </div>
                        </div>
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">工号</label>
                            <div class="col-sm-8">
                                 <input name="no" type="text" class="form-control" value="${user.no}" >
                            </div>
                        </div>
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">电话</label>
                            <div class="col-sm-8">
                                <input name="phone" type="text" class="form-control"  value="${user.phone}">
                            </div>
                        </div>
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">手机</label>
                            <div class="col-sm-8">
                                <input name="mobile" type="text" class="form-control" value="${user.mobile}">
                            </div>
                        </div>
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">邮箱</label>
                            <div class="col-sm-8">
                                 <input name="email" type="email" class="form-control" value="${user.email}" >
                            </div>
                        </div>
                        
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">备注</label>
                            <div class="col-sm-8">
                                 <textarea  name="remarks" class="form-control" style="height: 120px;">${user.remarks}</textarea>
                            </div>
                        </div>
	                	
	                	<div class="info-split">
                           	 账号信息
                        </div>
	                	
	                	<div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">账号</label>
                            <div class="col-sm-8">
                                <input name="loginName" type="text" class="form-control" value="${user.loginName}"  <c:if test="${not empty user.id}">readonly</c:if>>
                            </div>
                        </div>
                        
                        <c:if test="${empty user.id}">
		                	<div class="form-group m-b-bg">
	                            <label class="col-sm-2 control-label">密码</label>
	                            <div class="col-sm-8">
	                                <input id="password" name="password" class="form-control" type="password">
	                            </div>
	                        </div>
	                        <div class="form-group m-b-bg">
	                            <label class="col-sm-2 control-label">确认密码</label>
	                            <div class="col-sm-8">
	                                <input id="confirm_password" name="confirm_password" class="form-control" type="password">
	                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
	                            </div>
	                        </div>
                        </c:if>
                        
                        <c:if test="${not empty user.id}">
		                	<div class="form-group m-b-bg">
	                            <label class="col-sm-2 control-label">原始密码</label>
	                            <div class="col-sm-8">
	                                <input id="password" name="password" class="form-control" type="password">
	                            </div>
	                        </div>
	                        <div class="form-group m-b-bg">
	                            <label class="col-sm-2 control-label">新密码</label>
	                            <div class="col-sm-8">
	                                <input id="newPassword" name="newPassword" class="form-control" type="password">
	                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
	                            </div>
	                        </div>
                        </c:if>
                        
                        <div class="info-split">
                           	 权限信息
                        </div>
                        <div class="form-group m-b-bg">
							<label class="col-sm-2 control-label">用户类型:</label>
							<div class="col-sm-8">
								<select class="form-control" name="userType">
                                    <c:forEach items="${fns:getDictList('sys_user_type')}" var="userType" varStatus="idxStatus">
	                                    <option value="${userType.value}" <c:if test="${userType.value.equals(user.userType)}">selected</c:if>>${userType.lable}</option>
		                        	</c:forEach>
                                </select>
							</div>
						</div>
						<div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">用户角色</label>
                            <div class="col-sm-8">
                                <c:forEach items="${allRoles}" var="role" varStatus="idxStatus">
									<label class="checkbox-inline i-checks">
										<c:if test="${role.checked}">
											<input type="checkbox" checked="checked" name="roleIdList" value="${role.id}">${role.name}
										</c:if>
										<c:if test="${!role.checked}">
											<input type="checkbox" name="roleIdList" value="${role.id}">${role.name}
										</c:if>
									</label>
								</c:forEach>
                            </div>
                        </div>
                        <div class="form-group m-b-bg">
                            <label class="col-sm-2 control-label">是否允许登录</label>
                            <div class="col-sm-8">
								<label class="checkbox-inline i-checks">
									<input type="radio" <c:if test="${user.loginFlag}">checked</c:if> name="loginFlag" value="1">是
								</label>
								<label class="checkbox-inline i-checks">
									<input type="radio" <c:if test="${!user.loginFlag}">checked</c:if> name="loginFlag" value="0">否
								</label>
                            </div>
                        </div>
                        
                        
                        
                         <div class="form-group">
                             <div class="col-sm-4 col-sm-offset-4">
                                 <button class="btn btn-primary" type="submit">保 存</button>
                                 <button class="btn btn-white" type="button" onclick="history.go(-1)">返 回</button>
                             </div>
                         </div>
	                </form:form> 
	                </div>
	                	
                </div>
            </div>
        </div>
    </div>
    
    
    <script>
        $(document).ready(function(){
        	$(".i-checks").iCheck({
        		checkboxClass:"icheckbox_square-green",
        		radioClass:"iradio_square-green"
        	});
        	
        	/* $("#userForm").validate({
				submitHandler: function(form){
					form.submit();
				},
        	}); */
        	
		});
    </script>
</body>
</html>
